using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

namespace BlogControl
{
    class HtmlManager
    {
        internal static void RenderTextBox(HtmlTextWriter writer, string id, string name)
        {
            writer.WriteBeginTag("input");
            if (id != null)
            {
                writer.WriteAttribute("id", id);
            }
            if (name != null)
            {
                writer.WriteAttribute("name", name);
            }
            writer.WriteAttribute("type", "text");
            writer.Write(HtmlTextWriter.SelfClosingTagEnd);
        }

        internal static void SetFontStyles(System.Web.UI.WebControls.FontInfo fi, HtmlTextWriter writer)
        {
            if (fi.Bold)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
            }
            if (fi.Name != string.Empty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, fi.Name);
            }
            if (fi.Names.Length > 0)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, string.Join(",", fi.Names));
            }
            if (fi.Italic)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "italic");
            }
            if (fi.Overline)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "overline");
            }
            if (!fi.Size.IsEmpty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fi.Size.ToString());
            }
            if (fi.Strikeout)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "strikeout");
            }
            if (fi.Underline)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "underline");
            }
            
        }

        internal static void SetBorderStyle(HtmlTextWriter writer, BorderStyle borderStyle, Color color, string width)
        {
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, borderStyle.ToString());
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, width);
        }
    }
}
